package day8;

import javax.print.attribute.standard.MediaSize;

//实现一个接口 实现run()
public class TestRunnable implements Runnable{
    //线程的执行逻辑
    public void run() {
        String name = Thread.currentThread().getName();
        for (int i = 0; i < 10; i++) {
            System.out.println(name+" "+i);
        }
    }
    public static void main(String[] args) {
        //不是线程对象(跟Thread类无关) 只是线程的执行规则
        TestRunnable tr = new TestRunnable();
        //t1 t2 才是实现对象
        Thread t1 = new Thread(tr,"A");
        Thread t2 = new Thread(tr,"B");
        Thread t3 = new Thread(()->{
            for (int i = 10; i < 20; i++) {
                String name = Thread.currentThread().getName();
                System.out.println(name+" "+i);
            }
        },"C");
        t1.start();
        t2.start();
        t3.start();
    }
}
